package top.humbleyuan.linkedlist;

import top.humbleyuan.datastructure.linkedlist.LinkNode;

/**
 * @Author HumbleYuan
 * @Date 2020/5/18 22:40
 * @Des 奇偶链表
 */
public class LeetCode_324 {
    public static void main(String[] args) {
        LinkNode head = new LinkNode(3);
        int[] vals = {};
        head = LinkNode.formLink(head,vals);

        LinkNode oddHead = head;
        LinkNode evenHead = head.next;

        LinkNode oddTemp = oddHead;
        LinkNode evenTemp = evenHead;
        while (oddTemp.next != null && (evenTemp != null && evenTemp.next != null)) {
            oddTemp.next = oddTemp.next.next;
            evenTemp.next = evenTemp.next.next;

            oddTemp = oddTemp.next;
            evenTemp = evenTemp.next;
        }
        oddTemp.next = evenHead;

        LinkNode.headToString(oddHead);
    }
}
